<!DOCTYPE html>
{% load static %}
<html lang="zh-hans">
<head>
    <meta charset="UTF-8">
    <title>分类管理 - 我的博客</title>
    <link rel="stylesheet" href="{% static 'users/bulma.css' %}">
    <script src="{% static 'users/js/all.min.js' %}"></script>
    <style>
        .management-container {
            max-width: 800px;
            margin: 2rem auto;
            padding: 0 1rem;
        }
        .category-card {
            transition: transform 0.2s;
            margin-bottom: 1rem;
        }
        .category-card:hover {
            transform: translateY(-3px);
            box-shadow: 0 2px 6px rgba(0,0,0,0.1);
        }
        .card-footer {
            border-top: 1px solid #eee;
            background: #f5f5f5;
        }
        .has-text-danger {
            color: #ff3860 !important;
        }
        .fa-trash {
            font-size: 1.2rem;
            vertical-align: middle;
        }
    </style>
</head>
<body>

    <!-- 主内容 -->
    <div class="management-container">
        <div class="box is-shadowless">
            <h2 class="title is-4 mb-5">分类管理</h2>
            <p>分类数量：{{ categories|length }}</p>  <!-- 调试信息 -->

            <div class="columns is-multiline">
                {% for category in categories %}
                <div class="column is-4">
                    <div class="card category-card">
                        <div class="card-content">
                            <h3 class="title is-5">{{ category.name }}</h3>
                            <p class="has-text-grey">
                                {{ category.desc|truncatechars:20|default:"暂无描述" }}
                            </p>
                        </div>
                        <footer class="card-footer">
                            <a href="{% url 'blog:delete_category' category.id %}"
                               class="card-footer-item has-text-danger">
                                <i class="fas fa-trash"></i> 删除
                            </a>
                        </footer>
                    </div>
                </div>
                {% empty %}
                <div class="column">
                    <p class="has-text-centered">暂无分类</p>
                </div>
                {% endfor %}
            </div>
        </div>
    </div>

</body>
</html>